package com.zut.service.impl;

import com.zut.dao.ScoreDao;
import com.zut.dao.impl.ScoreDaoImpl;
import com.zut.service.ScoreService;

import java.util.List;
import java.util.Map;

/**
 * 成绩业务实现类
 */
public class ScoreServiceImpl implements ScoreService {

    //成绩持久层对象
    private ScoreDao sd = new ScoreDaoImpl();


    /**
     * 添加成绩
     * @param stuId
     * @param id
     * @param grade
     */
    @Override
    public void addScore(String stuId, int id, String grade) {

        sd.addScore(stuId,id,grade);
    }

    /**
     * 查询教师教授的学生成绩
     * @param tid
     * @param id
     * @return
     */
    @Override
    public List<Map<String, Object>> findScoresByTidAndCid(String tid, int id) {
        return sd.findScoresByTidAndCid(tid,id);
    }

    /**
     * 修改学生成绩
     *
     * @param stuId
     * @param id
     * @param newGrade
     * @return
     */
    @Override
    public boolean updateGrade(String stuId, int id, String newGrade) {

        int i = sd.updateGrade(stuId,id,newGrade);

        return i>0;
    }

    /**
     * 删除教授的课程成绩
     * @param stuId
     * @param id
     * @return
     */
    @Override
    public boolean deleteScoreBySidAndCid(String stuId, int id) {

       int i =  sd.deleteScore(stuId,id);

        return i>0;
    }

    /**
     * 查询学生各科成绩
     * @param id
     * @return
     */
    @Override
    public List<Map<String, Object>> findScoresBySid(String id) {

        return sd.findScoresBySid(id);
    }
}
